<div class="system-user">
	<nz-card [nzLoading]="isCardLoading" class="system-card" nzTitle="组织架构" [nzExtra]="extraTemplate">
		<nz-tree-view [nzTreeControl]="treeControl" [nzDataSource]="dataSource" [nzDirectoryTree]="true">
			<nz-tree-node *nzTreeNodeDef="let node" nzTreeNodePadding>
				<nz-tree-node-toggle nzTreeNodeNoopToggle></nz-tree-node-toggle>
				<nz-tree-node-option [nzDisabled]="node.disabled" [nzSelected]="selectListSelection.isSelected(node)"
					(nzClick)="selectListSelection.toggle(node)">
					<i nz-icon nzType="file" nzTheme="outline"></i>
					{{ node.name }}
				</nz-tree-node-option>
			</nz-tree-node>

			<nz-tree-node *nzTreeNodeDef="let node; when: hasChild" nzTreeNodePadding>
				<nz-tree-node-toggle>
					<i nz-icon nzType="caret-down" nzTreeNodeToggleRotateIcon></i>
				</nz-tree-node-toggle>
				<nz-tree-node-option [nzDisabled]="node.disabled" [nzSelected]="selectListSelection.isSelected(node)"
					(nzClick)="selectListSelection.toggle(node)">
					<i nz-icon [nzType]="treeControl.isExpanded(node) ? 'folder-open' : 'folder'" nzTheme="outline"></i>
					{{ node.name }}
				</nz-tree-node-option>
			</nz-tree-node>
		</nz-tree-view>
	</nz-card>

	<ng-template #extraTemplate>
		<a (click)="reload()">
			<i nz-icon nzType="reload" [nzSpin]="isReload" nzTheme="outline" style="font-size: 17px;"></i>
		</a>
	</ng-template>


	<div class="system-user-table page-content ">
		<form nz-form [formGroup]="validateForm" class="page-header">
			<div nz-row [nzGutter]="24">
				<div nz-col [nzSpan]="6">
					<nz-form-item>
						<nz-form-label nzFor="userName">用户名</nz-form-label>
						<nz-form-control>
							<input nz-input placeholder="请填写" formControlName="userName" />
						</nz-form-control>
					</nz-form-item>
				</div>

				<div nz-col [nzSpan]="6" [nzOffset]="12">
					<nz-form-item style="float: right;">
						<button *ngIf="authList.includes(authEnum.SYSTEM_USER_VIEW)" nz-button style="margin-right: 10px;" (click)="onSearch(true)">
							<i nz-icon nzType="search"></i>
							搜索
						</button>
						<button *ngIf="authList.includes(authEnum.SYSTEM_USER_ADD)" nz-button nzType="primary" (click)="addUser()">
							<i nz-icon nzType="plus"></i>
							新增
						</button>
					</nz-form-item>
				</div>

			</div>

		</form>


		<nz-table #basicTable [nzData]="data" [nzBordered]="true" [nzShowPagination]="false" nzSize="middle"
			[nzScroll]="{y:  'calc(100vh - 190px'}" [nzLoading]="nzLoading" [nzPageSize]="page.limit">
			<thead>
				<tr>
					<th nzAlign="center" nzWidth="50px">序号</th>
					<th nzAlign="center" nzWidth="auto">所属部门</th>
					<th nzAlign="center" nzWidth="auto">账号</th>
					<th nzAlign="center" nzWidth="auto">名称</th>
					<th nzAlign="center" nzWidth="auto">电话</th>
					<th nzAlign="center" nzWidth="180px">操作</th>
				</tr>
			</thead>
			<tbody>
				<tr *ngFor="let item of basicTable.data; let i = index;">
					<td nzAlign="center">{{ i + 1}}</td>
					<td nzAlign="center">
						<span class="line-clamp" nz-tooltip [nzTooltipTitle]="item?.deptName">
							{{item?.deptName}}
						</span>
					</td>
					<td nzAlign="center">
						{{item.loginName}}
					</td>
					<td nzAlign="center">
						{{item.userName}}
					</td>
					<td nzAlign="center">
						{{item.mobile}}
					</td>
					<td nzAlign="center">
						<ng-container *ngIf="authList.includes(authEnum.SYSTEM_USER_EDIT)">
							<a (click)="addUser(item)">编辑</a>
						</ng-container>
						
						<nz-divider *ngIf="authList.includes(authEnum.SYSTEM_USER_EDIT) && authList.includes(authEnum.SYSTEM_USER_DEL)" nzType="vertical"></nz-divider>
						<ng-container *ngIf="authList.includes(authEnum.SYSTEM_USER_DEL)">
							<a nz-popconfirm nzPopconfirmTitle="确定删除吗?" (nzOnConfirm)="del(item)">删除</a>
						</ng-container>

						<ng-container *ngIf="authList.includes(authEnum.SYSTEM_USER_EDIT)">
							<nz-divider nzType="vertical"></nz-divider>
							<a (click)="resetPwd(item)">重置密码</a>
						</ng-container>
						
						
					</td>
				</tr>
			</tbody>
		</nz-table>

		<div class="page-pagination">
			<span *ngIf="page.total">共{{page.total}}条数据</span>
			<nz-pagination [(nzPageIndex)]="page.page" [nzTotal]="page.total" nzShowQuickJumper nzShowSizeChanger
				[(nzPageSize)]="page.limit" (nzPageIndexChange)="pageChange()" (nzPageSizeChange)="pageChange(true)">
			</nz-pagination>
		</div>

	</div>

</div>